import {
    createDomFromString
} from './utils.js';
class Component {
    constructor(props={}) {
        this.props = props;
        // console.log('props',props)
    }
    setState(state) {
        let oldEl = this.el;
        this.state = state;
        this.el = this._renderDom();
        if (this.onStateChange) {
            this.onStateChange(oldEl, this.el);
        }
    }

    _renderDom() {
        console.log('this',this)
        this.el = createDomFromString(this.render());
        if (this.onClick) {
            this.el.addEventListener('click', this.onClick.bind(this), false);
        }
        return this.el;
    }
}

export default Component;